home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / Xteq X-Setup / xqdcXSP-Setup-EN.exe / {app} / plugins / XQ Startup Group 1.xpl < prev    next >
Text File  |  2004-02-21  |  6KB  |  227 lines

  1. "FILE"="Xteq Systems X-Setup Plugin 5.0"
  2. "TYPE"="9"
  3. "COUNT"="1"
  4. "UIPATH 1"="Startup/Shutdown\Startup\Windows 9x/ME\80) Windows Launch"
  5. "UIPATH 2"="Startup/Shutdown\Startup\Windows NT/2K/XP\60) Windows Launch"
  6. "NAME"=""StartUp" Group (Current User)"
  7. "LANGUAGE"="VBScript"
  8. "VERSION"="2.05"
  9. "TEXT 1"="dⁿdel dumm"
  10. "DESCRIPTION 1"="This plug-in lets you control which programs are currently inside the "StartUp" folder of your Start Menu."
  11. "DESCRIPTION 2"="All items inside this folder are automatically executed when Windows starts." 
  12. "DESCRIPTION 2"="To prevent an item from starting, disable the checkbox next to it."
  13. "DESCRIPTION 3"="Please note: This plug-in will create a folder "Disabled" in your "StartUp" group where all disabled items are stored. Once you have enabled those items again, this "Disabled" folder is deleted."
  14. "DESCRIPTION 4"="To add an item to this list, just point your mouse to this folder in your Start Menu, right-click and select "Open". Next, right-click again and select "New" -> "Shortcut"."
  15. "COMMENT 1"="Thanks to G÷ran ┼berg [abbe.ema@home.se] for the idea"
  16. "AUTHOR"="Xteq Systems"
  17. "CONTACTURL"="http://www.xteq.com/"
  18. "COPYRIGHT"="Copyright ⌐ Xteq Systems - All Rights Reserved"
  19.  
  20.  
  21. ' Where to find the Startup Folder:
  22. sV1="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Startup"
  23.  
  24. Dim iFiles   'conatins how many are currently displayed in the UI
  25. Dim aryFiles() 'contains all the files
  26.  
  27. Dim sPathActive 
  28. Dim sPathInactive
  29.  
  30.  
  31. Sub Plugin_Initialize 
  32.  s=RegReadValue(sV1)
  33.  if len(s)<=0 then
  34.     Call Disable
  35.  else
  36.     if right(s,1)="\" then
  37.        s=left(s,len(s)-1)
  38.     end if
  39.  
  40.     sPathActive=s
  41.  
  42.     ' create the inactive path
  43.     iPos=InStrRev(sPathActive,"\")
  44.     if iPos>0 then
  45.        sName=Right(sPathActive,len(sPathActive)-iPos)
  46.        sPath=Left(sPathActive,iPos)       
  47.        sPathInactive=sPath & "Disabled " & sName & " Items"
  48.        
  49.        Call ReadFiles
  50.     else
  51.        Call Disable()   
  52.        Call MsgError("Unable to retrieve name of Startup Group - can not continue")   
  53.     end if
  54.  end if
  55. End Sub
  56.  
  57.  
  58. Sub ReadFiles
  59.    'first, clear the UI
  60.     for l=1 to iFiles
  61.         Call SetUIElement(l,"")
  62.     next 
  63.  
  64.    'read active items
  65.    dim aryTemp1
  66.    i=FileEnum(sPathActive & "\*.*")
  67.    ReDim aryTemp1(i)
  68.  
  69.    for l=1 to i
  70.        s=FileEnumElement(l)
  71.        if CheckDesktopIni(s)=false then aryTemp1(l)=s
  72.    next
  73.  
  74.    'read inactive items
  75.    dim aryTemp2
  76.    i=FileEnum(sPathInactive & "\*.*")
  77.    ReDim aryTemp2(i)
  78.  
  79.    for l=1 to i
  80.        s=FileEnumElement(l)
  81.        if CheckDesktopIni(s)=false then aryTemp2(l)=s
  82.    next
  83.  
  84.    '---------------------------------------
  85.    'okay, we now have two arrays (aryTemp2 and aryTemp4) that contain
  86.    'all the items that we need. We now simply need to create ONE array from those two
  87.  
  88.     iFiles=uBound(aryTemp1)+UBound(aryTemp2)
  89.     ReDim aryFiles(iFiles)
  90.     
  91.     for l=1 to UBound(aryTemp1)
  92.         aryFiles(l)=aryTemp1(l)
  93.     next
  94.  
  95.     for i=1 to UBound(aryTemp2)
  96.         aryFiles(UBound(aryTemp1)+i)=aryTemp2(i)
  97.     next 
  98.  
  99.    '--------------------------------------- 
  100.    'finally, update the UI
  101.  
  102.    for l=1 to UBound(aryFiles)
  103.        sItem=aryFiles(l)
  104.  
  105.        iPos=InStrRev(sItem,"\")
  106.        if iPos>0 then
  107.           sName=Right(sItem,len(sItem)-iPos)
  108.        else 
  109.           sName=sItem
  110.        end if
  111.         
  112.        bActivated=0
  113.        if InStr(sItem,sPathInactive)>0 then
  114.           bActivated=false
  115.        else
  116.           bActivated=true
  117.        end if
  118.  
  119.  
  120.        Call SetUIElement(l,sName)
  121.        Call SetUIElementEx(l,bActivated)
  122.    next   
  123. End Sub
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Sub Plugin_Apply(ElementIndex,ElementSubIndex)
  131.     bChanges=false
  132.  
  133.     for l=1 to UBound(aryFiles)
  134.         sItem=aryFiles(l)
  135.         bUI=GetUIElementEx(l)   
  136.   
  137.         if InStr(sItem,sPathInactive)>0 then
  138.            bActive=false
  139.         else
  140.            bActive=true
  141.         end if
  142.  
  143.  
  144.        'now check for differences between bReg and bUI
  145.        if bUI=true and bActive=true then
  146.            'do nothing, both activated
  147.         else
  148.            if bUI=false and bActive=false then
  149.               'do nothing, both deactivated
  150.            else
  151.  
  152.               if bUI=true and bActive=false then 
  153.                  'in UI activated, in STARTUP Deactivated ->
  154.                  sOldPath=sItem
  155.                  sNewPath=Replace(sOldPath,sPathInactive,sPathActive) 
  156.               else                
  157.                  'in UI deactivated, in STARTUP activated ->
  158.                  sOldPath=sItem
  159.                  sNewPath=Replace(sOldPath,sPathActive,sPathInactive) 
  160.               end if  
  161.  
  162.               'DebugMsg sOldPath & " ** " & sNewPath
  163.  
  164.               'delete any existing file...
  165.               If FileExists(sNewPath)=true then
  166.                  Call FileDelete(sNewPath)
  167.               end if
  168.               
  169.               'does disabled folder exist?
  170.               If FolderExists(sPathInactive)=false then
  171.                  Call FolderCreate(sPathInactive)
  172.               end if
  173.  
  174.               'copy file
  175.               Call FileCopy(sOldPath,sNewPath)
  176.               Call FileDelete(sOldPath)
  177.  
  178.               'check if we can remove the disabled folder...
  179.               i=FileEnum(sPathInactive & "\*.*")
  180.               if i<=0 then 'folder empty..
  181.                  Call FolderDelete(sPathInactive)
  182.               end if
  183.                
  184.  
  185.               'set flag
  186.               bChanges=true
  187.            end if
  188.         end if
  189.  
  190.     next 
  191.  
  192.  
  193.     if bChanges=true then
  194.        Call ReadFiles
  195.  
  196.        'call the holy Windows API
  197.        Call IndicateSettingChange()
  198.  
  199.     end if
  200. End Sub
  201.  
  202.  
  203.  
  204. Sub Plugin_Terminate 
  205. End Sub
  206.  
  207. Function CheckDesktopIni(InStr)
  208.  CheckDesktopIni=false
  209.  
  210.  if len(InStr)>11 then 'length of DESKTOP.INI
  211.     iPos=InStrRev(InStr,"\")
  212.     if iPos>0 then
  213.        sName=Right(InStr,len(InStr)-iPos)
  214.     else 
  215.        sName=InStr
  216.     end if
  217.  
  218.     if UCase(sName)="DESKTOP.INI" then
  219.        CheckDesktopIni=true  
  220.     end if
  221.  end if
  222.  
  223. End Function
  224.  
  225.  
  226.  
  227.